package com.e3.basdoc.warehouse.service;

import java.util.List;

import com.e3.basdoc.warehouse.model.WarehouseModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class WarehouseCacheLoader implements CacheLoader {
	
	private WarehouseQueryService queryService;
	
	private WarehouseQueryService getWarehouseQueryService(){
		if(queryService == null){
			queryService = ServiceLocator.getQueryService(WarehouseQueryService.class);
		}
		return queryService;
	}

	public void loadeData() throws Exception {
		List<WarehouseModel> models = getWarehouseQueryService().getAllWarehouses();
		if(models==null||models.isEmpty()){
			return;
		}
		for (WarehouseModel model : models) {
			WarehouseCacheManager.INSTANCE.put(model);
		}

	}

}
